//
//  MantisRightImgTableViewCell.m
//  NLProjectFrameworkDemo
//
//  Created by iosdeveloper on 2020/5/10.
//  Copyright © 2020 yj_zhang. All rights reserved.
//

#import "MantisRightImgTableViewCell.h"

@implementation MantisRightImgTableViewCell
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self=[super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        [self setUpView];
    }
    return self;
}

-(void)setUpView{
    [super  setUpView];
    self.contentLabel.hidden=YES;//隐藏基类里面的文字
   
    UIImageView*photoImgView =[UIImageView new];
    photoImgView.backgroundColor =self.bgView.backgroundColor;
    self.photoImg=photoImgView;
    photoImgView.contentMode=UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:photoImgView];
    CGSize bgSize =CGSizeMake(adaptWidth750(120*2), adaptWidth750(80*2));
    [photoImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(self.avaterView.mas_left).offset(-adaptWidth750(20));
        make.top.equalTo(self.avaterView);
        make.size.mas_equalTo(bgSize);
        
    }];
    
    [self setThreeCorner:bgSize bgView:(UIView*)self.photoImg];//对图片切角
    
    [self.errorBtn mas_makeConstraints:^(MASConstraintMaker *make) {
           make.right.equalTo(photoImgView.mas_left).offset(-adaptWidth750(20));
           make.centerY.equalTo(photoImgView);
       }];
    
   
    
    
}

-(void)reloadCellModel:(MantisCellBaseModel *)data{
    MantisImageMessageCellData*newData =(MantisImageMessageCellData*)data;
//    WS(weakSelf);
    self.cellBaseData=newData;
    if ([newData.content containsString:@"src"]) {//从服务器拿下来的url
    
        NSString*imgUrl =newData.content;
       imgUrl= [imgUrl stringByReplacingOccurrencesOfString:@"<img src='" withString:@""];
        imgUrl= [imgUrl stringByReplacingOccurrencesOfString:@"' />" withString:@""];
       imgUrl= [imgUrl stringByReplacingOccurrencesOfString:@"<img src=\"" withString:@""];
        imgUrl= [imgUrl stringByReplacingOccurrencesOfString:@"\">" withString:@""];
        [self.photoImg setImageWithURL:[NSURL URLWithString:imgUrl]placeholder:KdefaultAVater];
        
    }else{
        self.photoImg.image=newData.photoImg;//本地显示图片
    }
    
//    if (data.isShowActivity) {
//        self.isShowActivity=YES;
//           [weakSelf.indicator mas_makeConstraints:^(MASConstraintMaker *make) {
//               make.right.equalTo(weakSelf.photoImg.mas_left).offset(-adaptWidth750(10));
//               make.centerY.equalTo(weakSelf.photoImg);
//           }];
//    }else{
//        self.isShowActivity=NO;
//    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
